const WindowsBot = require('WindowsBot');//引用WindowsBot模块

//注册主函数
WindowsBot.registerMain(windowsMain, "127.0.0.1", 26678);

/**用作代码提示，windowsMain函数会被多次调用，注意使用全局变量
* @param {WindowsBot} windowsBot
*/
async function windowsMain(windowsBot){
    //设置隐式等待
    await windowsBot.setImplicitTimeout(1000);

    let hwnd = await windowsBot.findWindow(null, "运行");
    console.log("hwnd",hwnd)
    if(hwnd ==  null)
    {
        console.log("hwnd没有启动，我去启动一下")
        await windowsBot.startProcess("cmd.exe", showWindow = true, isWait = false);
    }

    let subHwnd = await windowsBot.getElementWindow(hwnd, "ComboBox/Edit"); 
    //await windowsBot.clickElement(hwnd, "Window/Button[2]", 1);
    //await windowsBot.sendData("sendKeys", hwnd, "1876717017"); 
    await windowsBot.sendKeysByHwnd(subHwnd, "1876717017");

}